<template lang="">
  <div>
    <button @click="login">登录</button>
    <button @click="logout" v-if="loginStore.isLoggedIn">登出</button>
    <p v-if="loginStore.isLoggedIn">欢迎，{{ loginStore.username}},登录成功</p>
  </div>
</template>
<script setup>
import { ref, reactive, onMounted } from "vue";
import { useLoginStore } from "../store";
import { useRoute, useRouter } from "vue-router";
const router = useRouter();
const data = reactive({});
const loginStore = useLoginStore();
const login = () => {
  loginStore.login("王先生");
  setTimeout(()=>{
   router.back()
  },1000)

};
const logout = () => {
  loginStore.logout();
};

onMounted(() => {});
</script>
<style lang="">
</style>